package com.company.OfferGuide;

import java.util.Stack;

public class 用两个栈实现队列 {

    Stack<Integer> stack01 = new Stack<>();
    Stack<Integer> stack02 = new Stack<>();

    public void CQueue() {

    }

    public void appendTail(int value) {
        stack01.push(value);

    }

    public int deleteHead() {
        if (stack02.isEmpty()) {
            while (!stack01.isEmpty()) {
                stack02.push(stack01.pop());
            }
            if (stack02.isEmpty()) return -1;
            else return stack02.pop();
        } else {
            return stack02.pop();
        }
    }

}
